FindMemoryRunLength
Steps = FindMemoryRunLength(Address, Direction, MaxDistance, PatternType, SearchPattern)
 
Parameters:

    Address = The Address in memory to start searching at
    Direction = The direction to search (-1 = backwards, 1 = forward)
    MaxDistance = The Max length it should scan for
    PatternType = The type of compare it should use (1= byte, 2= word, 4 =long)
    SearchPattern = The byte pattern we've expect to the find the run length of
Returns:

    Steps = The Number of steps (bytes/word/longs) that are the same
 

      The FindMemoryRunLength() will find the length of a run of byte/words or longs in memory.

Pattern Types

1= Search is using a BYTE pattern
2= Search is using a WORD pattern
4= Search is using a LONG pattern



FACTS:


      * FindMemoryRunLength is dealing with raw memory, as such, PlayBASIC can not protect you from making mistakes. Thus FindMemoryRunLength assumes the memory area you give it is valid, if not, you should expect your program to crash !



Mini Tutorial:


      This example finds the length of a run of zero bytes in a memory bank.


  
  
; create a bank that's 100 bytes in size
  CreateBank 1,100
  
; put the byte 255 in bank#1 at offset 75
  PokeBankByte 1,75,255
  
; get the start address of this bank in memory
  Address=GetBankPtr(1)
  
; find the length of run of zero byte from the banks start address
  Size=FindMemoryRunLength(Address,1,100,1,0)
  
; display the size
  Print size
  
; refresh the screen and wait for a key input
  Sync
  WaitKey
  
  




This example would output.

  
  75
  

 
Related Info: CompareMemory | CopyMemory | FillMemory | GetArrayPtr | PeekByte | Pointer :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com